﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FanPages.Common;
using FanPages.Server.Services.Contracts.Dto;
using FanPages.Server.Repostory.EFRepository.Model;

namespace FanPages.Server.Services.Transformers
{
    public class SearchResultTransformerSvc : ITransformer<SearchResult, SearchResultDto> 
    {

        public SearchResultDto ToDto(SearchResult clientEntity)
        {
            SearchResultDto dto = new SearchResultDto()
            {
                Snippet = clientEntity.Snippet.ToString(),
                ResultDate = clientEntity.ResultDate,
                Name = clientEntity.Name,
                Link = clientEntity.Link,
                HtmlTile = clientEntity.HtmlTile,
                HtmlSnippet = clientEntity.HtmlSnippet.ToString(),
                FanItemDto = new FanItemTransformerSvc().ToDto(clientEntity.FanItem),
                DisplayLink = clientEntity.DisplayLink,
                CachedId = clientEntity.CachedId
            };
            return dto;
        }

        public SearchResult ToClient(SearchResultDto dtoEntity)
        {
            throw new NotImplementedException();
        }


        public List<SearchResultDto> ToListDto(List<SearchResult> list)
        {
            var newList = new List<SearchResultDto>();
            foreach (var item in list)
            {
                newList.Add(ToDto(item));
            }
            return newList;
        }

        public List<SearchResult> ToListEntity(List<SearchResultDto> list)
        {
            throw new NotImplementedException();
        }
    }
}
